package com.xuerhua.yxt.controller.sys.signup;

import com.xuerhua.yxt.common.RspResult;
import com.xuerhua.yxt.common.enums.Status;
import com.xuerhua.yxt.controller.BaseController;
import com.xuerhua.yxt.model.Grid;
import com.xuerhua.yxt.model.MiddleStudentGrade;
import com.xuerhua.yxt.service.IStudentSignUpService;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("sys/signUp/middleStudentGrade")
@Controller
public class SysMiddleStudentGradeConfController extends BaseController {

    @Autowired
    private IStudentSignUpService studentSignUpService;

    @RequestMapping(value = {"", "/"})
    public String Index() {
        return "sys/signup/middleStudentGrade";
    }

    @RequestMapping("pageQuery")
    @ResponseBody
    Object pageQuery(Integer schoolId) {
        try {
            MiddleStudentGrade record = this.studentSignUpService.selectMiddleStudentGrade(schoolId);
            List list = new ArrayList();
            list.add(record);
            Grid grid = new Grid();
            grid.setRows(list);
            grid.setTotal(list.size());
            return grid;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    @RequestMapping("addUpdate")
    @ResponseBody
    Object pageQuery(MiddleStudentGrade record) {
        try {
            this.studentSignUpService.updateMiddleStudentGrade(record);
            return new RspResult(Status.SUCCESS);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new RspResult(Status.FAIL);
    }
}